// Copyright (c) 2002 Torvald Riegel. All rights reserved.
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.

package cpne;

import org.tigris.gef.base.*;
import org.tigris.gef.presentation.*;
import org.tigris.gef.graph.presentation.*;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;


public class PTEdge extends NetEdge
{
    protected DefaultComboBoxModel typeModel;
    protected PerlExprDocument exprDocument;
    
    public PTEdge()
        {
            super();
            final String[] typeStrings ={"single", "permutation", "all"};
            typeModel = new DefaultComboBoxModel(typeStrings);
            exprDocument = new PerlExprDocument();
        }
    public ComboBoxModel getTypeModel()
        {
            return typeModel;
        }
    public Document getExprDocument()
        {
            return exprDocument;
        }
    
    public String getId()
        {
            return toString();
        }
    public FigEdge makePresentation(Layer lay)
        {
            FigEdge fe = new FigEdgeLine() 
                {
                    /** Computes the end-points of the line between the place
                     * and the transition. Asks the nodes at both ends for the
                     * Figs that represents their bounds. */
                    public void computeRoute()
                        {
                            Point srcPt = _sourceFigNode.center();
                            Point dstPt = _destFigNode.center();
                            if (_useNearest) {
                                srcPt = ((FigPlaceNode)_sourceFigNode).
                                    getBoundsFig().connectionPoint(dstPt);
                                dstPt = ((FigTransitionNode)_destFigNode).
                                    getBoundsFig().connectionPoint(srcPt);
                            }
                            ((FigLine) _fig).setShape(srcPt, dstPt);
                            calcBounds();
                        }
                };
            fe.setBetweenNearestPoints(true);
            fe.setLineWidth(2);
            fe.setDestArrowHead(new ArrowHeadTriangle());
            return fe;
        }
}
